package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.User;
import com.zr.service.Xbqdservice;
import com.zr.serviceImpl.XbqdserviceImpl;

public class XbqdController extends HttpServlet{
   Xbqdservice  x=new XbqdserviceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 SimpleDateFormat sdf =   new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss " ); 
		 SimpleDateFormat sd =   new SimpleDateFormat( "yyyy-MM-dd" ); 
		 String date=sdf.format(new Date());
		 String data=sd.format(new Date());
		 HttpSession session=req.getSession();
		 User u=(User) session.getAttribute("user");
		 String string=x.findcbsj(u.getUsernum());
		 PrintWriter pw=resp.getWriter();
		 if(data.equals(string)){
	           	pw.write("0");
	      }else{
	           	 boolean b= x.findxbqd(date);
	           	   if(b){
	     	        	 pw.write("true");
	     	         }else{
	     	        	 pw.write("false");
	     	         }
	           }
		 pw.flush();
		 pw.close();
	}
  
}
